home *** CD-ROM | disk | FTP | other *** search
-
-
-
- STAT(3) MINTLIB LIBRARY FUNCTIONS STAT(3)
-
-
- N✓NA✓AM✓ME✓E
- stat, lstat, fstat - get file status
-
- S✓SY✓YN✓NO✓OP✓PS✓SI✓IS✓S
- #include <sys/types.h>
- #include <sys/stat.h>
-
- int stat(const char *path, struct stat *buf);
-
- int lstat(const char *path, struct stat *buf);
-
- int fstat(int fd, struct stat *buf);
-
- D✓DE✓ES✓SC✓CR✓RI✓IP✓PT✓TI✓IO✓ON✓N
- stat obtains information about the file named by path.
- Read, write or execute permission of the named file is not
- required, but all directories listed in the path name
- leading to the file must be searchable.
-
- lstat is like stat except in the cases where the named
- file is a symbolic link, in which case lstat returns
- information about the link, while stat returns information
- about the file the link references.
-
- fstat obtains the same information about an open file ref-
- erenced by the the file descriptor, such as would be
- returned by an creat, open, dup, fcntl or pipe call.
-
- buf is a pointer to a stat structure into which informa-
- tion is placed concerning the file. The stat structure is
- defined in <sys/stat.h> and contains the following fields
- of interest:
- struct stat
- {
- u_short st_mode; /* file mode
- */
- ino_t st_ino; /* the file serial number
- */
- dev_t st_dev; /* device file resides on
- */
- short st_rdev; /* the device identifier
- */
- short st_nlink; /* number of hard links to the
- file */
- uid_t st_uid; /* user ID of the owner
- */
- gid_t st_gid; /* group ID of the owner
- */
- off_t st_size; /* total size of the file, in
- bytes */
- off_t st_blksize; /* preferred blocksize for system
- I/O */
- off_t st_blocks; /* actual number of blocks allo-
- cated */
-
-
-
- MiNT docs 0.1 3 March 1993 1
-
-
-
-
-
- STAT(3) MINTLIB LIBRARY FUNCTIONS STAT(3)
-
-
- time_t st_mtime; /* file last modify time
- */
- time_t st_atime; /* file last access time
- */
- time_t st_ctime; /* file last status change time
- */
- short st_attr; /* file attributes
- */
- ... /* various fields reserved for
- MiNT */
- };
-
- The following masks are available in <sys/stat.h> to test
- the st_mode field in the stat structure:
- #define S_IFMT 0170000 /* type of file */
- #define S_IFCHR 0020000 /* character special */
- #define S_IFDIR 0040000 /* directory */
- #define S_IFBLK 0060000 /* block special */
- #define S_IFREG 0100000 /* regular file */
- #define S_IFIFO 0120000 /* FIFO special */
- #define S_IMEM 0140000 /* shared memory (?) */
- #define S_IFLNK 0160000 /* symbolic link */
- #define S_ISUID 04000 /* set-uid on execution */
- #define S_ISGID 02000 /* set-gid on execution */
- #define S_ISVTX 01000 /* save swapped text */
-
- The following masks are available in <sys/stat.h> to test
- the st_attr field in the stat structure:
- #define S_IRUSR 0400 /* readable by user */
- #define S_IWUSR 0200 /* writeable by user */
- #define S_IXUSR 0100 /* executable by user */
- #define S_IRGRP 0040 /* readable by group */
- #define S_IWGRP 0020 /* writable by group */
- #define S_IXGRP 0010 /* executable by group */
- #define S_IROTH 0004 /* readable by others */
- #define S_IWOTH 0002 /* writable by others */
- #define S_IXOTH 0001 /* executable by others */
-
- R✓RE✓ET✓TU✓UR✓RN✓N V✓VA✓AL✓LU✓UE✓ES✓S
- 0 on success. -1 on failure; errno is set to indicate
- the error.
-
- S✓SE✓EE✓E A✓AL✓LS✓SO✓O
- c✓ch✓hm✓mo✓od✓d(✓(3✓3)✓),✓, c✓ch✓ho✓ow✓wn✓n(✓(3✓3)✓),✓, F✓Fc✓cn✓nt✓tl✓l(✓(2✓2)✓),✓, F✓Fx✓xa✓at✓tt✓tr✓r(✓(2✓2)✓)
-
- N✓NO✓OT✓TE✓E
- When MiNT is not active, these calls are emulated under
- TOS. The TOS implemenation of fstat in particular is
- pretty bogus. You are advised to read the source code of
- stat.c if you want to make use of other than the most
- basic attributes under TOS emulation.
-
-
-
-
-
-
- MiNT docs 0.1 3 March 1993 2
-
-
-